<?php

namespace App\Http\Controllers\PC\Buy;

use Illuminate\Http\Request;
use Config;
use Session;

use App\Http\Service\Product\ProductService;
use App\Http\Requests;
use App\Http\Controllers\Controller;



class BuyController extends Controller
{

    private $product = '';
    protected  $index = 'PC.Buy.index';

    public function __construct(ProductService $product)
    {
        $this->product = $product;
    }

    /**
     * @return $this
     *   购买视图
     */
    public function index()
    {
        $login_flag = 0;
        $username = '';
        if(Session::has(Config::get('custom.setting.MEMBER_TOKEN')) && !empty(Session::get(Config::get('custom.setting.MEMBER_TOKEN'))))
        {
            $login_flag = 1;
            $username = Session::get(Config::get('custom.setting.MEMBER_INFO'))['name'];

        }
        $ret = $this->product->Product();
        $data = [];
        $data = $ret['data'];

        $title="购买";
//        dd($data);
        return view($this->index)->with('data',$data)->with('login_flag',$login_flag)->with('name',$username)->with('title',$title);
    }
}
